﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using GameView.Comment;
using MaterialDesignThemes.Wpf;

namespace GameView.ViewModels
{
    public partial class MsgViewDialogViewModel : ObservableObject
    {
        /// <summary>
        /// 3001成功;3002失败;3003取消;3004提示
        /// </summary>
        /// <param name="tile"></param>
        /// <param name="type"></param>
        /// <param name="msg"></param>
        public MsgViewDialogViewModel(string tile, int type, string msg, string data, string msg1)
        {
            this.Tile = tile;
            this.Type = type;
            this.Msg1 = msg;
            this.Data1 = data;
            this.Msg2 = msg1;
        }

        public MsgViewDialogViewModel(string tile, int type, string msg, string data, string msg1, string data1, string msg2)
        {
            this.Tile = tile;
            this.Type = type;
            this.Msg1 = msg;
            this.Data1 = data;
            this.Msg2 = msg1;
            this.Data2 = data1;
            this.Msg3 = msg2;
        }

        /// <summary>
        /// 3001成功;3002失败;3003取消;3004提示
        /// </summary>
        /// <param name="tile"></param>
        /// <param name="type"></param>
        /// <param name="msg"></param>
        public MsgViewDialogViewModel(string tile, int type, string msg)
        {
            this.Tile = tile;
            this.Type = type;
            this.Msg1 = msg;
        }

        [ObservableProperty]
        private string _tile = string.Empty;

        [ObservableProperty]
        private int _type = 3004;

        [ObservableProperty]
        private int _status = 0;

        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(Data1Show))]
        private string _data1 = string.Empty;

        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(Data2Show))]
        private string _data2 = string.Empty;

        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(Data3Show))]
        private string _data3 = string.Empty;

        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(Msg1Show))]
        private string _msg1 = string.Empty;

        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(Msg2Show))]
        private string _msg2 = string.Empty;

        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(Msg3Show))]
        private string _msg3 = string.Empty;

        [ObservableProperty]
        [NotifyPropertyChangedFor(nameof(Msg4Show))]
        private string _msg4 = string.Empty;

        public string pp = "RootDialog";

        [ObservableProperty]
        private bool _hasCancel = true;

        private bool Data1Show => !Data1.IsNullOrEmpty();
        private bool Data2Show => !Data2.IsNullOrEmpty();
        private bool Data3Show => !Data3.IsNullOrEmpty();
        private bool Msg1Show => !Msg1.IsNullOrEmpty();
        private bool Msg2Show => !Msg2.IsNullOrEmpty();
        private bool Msg3Show => !Msg3.IsNullOrEmpty();
        private bool Msg4Show => !Msg4.IsNullOrEmpty();

        [RelayCommand]
        private void Confirm()
        {
            if (DialogHost.IsDialogOpen(pp))
            {
                DialogHost.Close(pp, true);
            }
            Status = 1;
        }

        [RelayCommand]
        private void Cancel()
        {
            if (DialogHost.IsDialogOpen(pp))
            {
                DialogHost.Close(pp, false);
            }
            Status = 0;
        }
    }
}